/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package descente;

import java.awt.Graphics;
import javax.swing.JPanel;

/**
 *
 * @author Hippolyte
 */
public class Paneau extends JPanel {

    private Graphics ag;

    public Paneau() {
        super();
    }

    @Override
    public void paintComponent(Graphics g) {
        this.setLayout(null);
        this.setBounds(0, 0, (int) (commerce.X_MAX + 25), (int) (commerce.Y_MAX + 55));


//        g.dispose();

        super.paintComponent(g);

//        for (Point p : Recuit.sTemp) {
//            g.fillRect((int) p.x, (int) p.y, 4, 4);
//
//        }

        for (int i = 0; i < Recuit.sTemp.size() - 1; i++) {
            g.fillRect((int) Recuit.sTemp.get(i).x, (int) Recuit.sTemp.get(i).y, 4, 4);
            g.drawLine((int) Recuit.sTemp.get(i).x+2, (int) Recuit.sTemp.get(i).y+2, 
                    (int) Recuit.sTemp.get(i + 1).x+2, (int) Recuit.sTemp.get(i + 1).y+2);
        }
        if (Recuit.sTemp.size() > 1) {
            //cout initialisé au cout du premier vers dernier point
            g.drawLine((int) Recuit.sTemp.get(Recuit.sTemp.size() - 1).x+2,
                    (int) Recuit.sTemp.get(Recuit.sTemp.size() - 1).y+2,
                    (int) Recuit.sTemp.get(0).x+2, (int) Recuit.sTemp.get(0).y+2);
        }
//        Recuit.f.pan.dessinerLigne(villes.get(villes.size() - 1), villes.get(0));


//        System.out.println("set ag");

        repaint();



    }

    public void dessinerPoint(int x, int y) {
        System.out.println("dessiner " + x + " " + y);
        ag.fillRect(x, y, 4, 4);
//        repaint();
    }

    public void dessinerLigne(Point p1, Point p2) {
        ag.drawLine((int) p1.x, (int) p1.y, (int) p2.x, (int) p2.y);
//        repaint();
    }
}
